function findAB(string){
    for(i = 0;i < string.length;++i){
        if(i != string.length -1
            &&string[i]=== 'a' 
            && string[i+1] === 'b'){
            return true;
        }
    }
    return false;
}

console.log(findAB("i hte code fuck "))

// 老师写的版本
function match(string){
    let foundA = false;
    for(let str of string){
        if(str === 'a'){
            foundA = true;
        }
        else if(foundA && str === 'b'){
            return true;
        }
        else 
            foundA = false;
    }
    return false;
}